<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page  import="user.com.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'renwen.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <style type="text/css">
    p.leftmargin {margin-left: 12cm}
    body {background-image:url(D:\Desktop\新建文件夹\02.jpg);}
    table
  {
  border-collapse:collapse;
  }

table, td, tr
  {
  border:1px solid blue;
  }

</style>
  </head>
  
<%! int pageSize=4; int pageCount; int showPage; %>
<body >
<header>
		<h1 align="center">南京邮电大学图书馆</h1>
	</header>
<%
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
Map<String,Object> map1=new HashMap<String,Object>();
String sql="renwen";
myjdbc my3=new myjdbc();
list=my3.fenye(sql);
int i=my3.select2("renwen");
if(i%10==0){
	pageCount=i/10;
}else{
	pageCount=i/10+1;
}

String integer=request.getParameter("showPage");
if(integer==null){
integer="1";
}
try{showPage=Integer.parseInt(integer);
}catch(NumberFormatException e){
showPage=1;
}
if(showPage<=1){
showPage=1;
}
if(showPage>=pageCount){
showPage=pageCount;
}
%>
<p class="leftmargin"><table >
<tr><td>序号</td><td>书名</td><td>作者</td><td>售价</td><td>出版日期</td></tr>
<% 
for(int j=(showPage-1)*10;(showPage-1)*10<=j&&j<=showPage*10-1;j++){
	map1=list.get(j);
%>

<tr> 
<td><%=map1.get("xuhao")%></td>
<td><%=map1.get("name") %></td>
<td><%=map1.get("zuozhe") %></td>
<td><%=map1.get("price") %></td>
<td><%=map1.get("riqi") %></td>
</tr>
<%
}
%>
</table></p>
<br>
<p class="leftmargin">第<%=showPage %>页 共<%=pageCount %>页
<br>
<a href="renwen.jsp?showPage=1">首页</a>
<a href="renwen.jsp?showPage=<%=showPage-1%>">上一页</a>
<%
for(int k=1;k<=pageCount;k++){
%>
<a href="renwen.jsp?showPage=<%=k%>"><%=k%></a>
<%}
%>
<a href="renwen.jsp?showPage=<%=showPage+1%>">下一页</a>
<a href="renwen.jsp?showPage=<%=pageCount%>">末页</a></p>
<p class="leftmargin"><form action="" method="get" >
  跳转到第<input type="text" name="showPage" size="4">页
  <input type="submit" name="submit" value="跳转">
 </form> <a href="./result4.jsp"> 返回首页</a> </p>  
  </body>
</html>
